home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / GKFUHW (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.3 KB  |  32 lines

  1. package sun.beans.editors;
  2.  
  3. import java.beans.PropertyEditorSupport;
  4.  
  5. public class BoolEditor extends PropertyEditorSupport {
  6.    public String getAsText() {
  7.       return (Boolean)((PropertyEditorSupport)this).getValue() ? "True" : "False";
  8.    }
  9.  
  10.    public String getJavaInitializationString() {
  11.       return (Boolean)((PropertyEditorSupport)this).getValue() ? "true" : "false";
  12.    }
  13.  
  14.    public String[] getTags() {
  15.       String[] result = new String[]{"True", "False"};
  16.       return result;
  17.    }
  18.  
  19.    public void setAsText(String text) throws IllegalArgumentException {
  20.       if (text.toLowerCase().equals("true")) {
  21.          ((PropertyEditorSupport)this).setValue(Boolean.TRUE);
  22.       } else {
  23.          if (!text.toLowerCase().equals("false")) {
  24.             throw new IllegalArgumentException(text);
  25.          }
  26.  
  27.          ((PropertyEditorSupport)this).setValue(Boolean.FALSE);
  28.       }
  29.  
  30.    }
  31. }
  32.